package parse;

import Const.Constant;
import RecordManagement.*;

public class Attribute{
	public String rel_name = null;
	public String attr_name = null;
	public String attr_newname = null;
	public int attr_type;
	public int attr_length;
	public boolean key = false;
	public boolean foreign_key = false;
	public String foreign_rel = null;
	public String foreign_attr = null;
	
	public Attribute(Attribute a, String s){
		this.rel_name = a.rel_name;
		this.attr_name = a.attr_name;
		this.attr_newname = s;
		this.attr_type = a.attr_type;
		this.attr_length = a.attr_length;
		this.key = a.key;
		this.foreign_key = a.foreign_key;
		this.foreign_rel = a.foreign_rel;
		this.foreign_attr = a.foreign_attr;
	}
	
	public Attribute(String rel_name, String attr_name){
		StringBuffer s = new StringBuffer(rel_name);
		s.setLength(Constant.MAXNAME);
		this.rel_name = s.toString();
		
		s = new StringBuffer(attr_name);
		s.setLength(Constant.MAXNAME);
		this.attr_name = s.toString();
		
	}
	
	public Attribute(String name){
		StringBuffer s = new StringBuffer(name);
		s.setLength(Constant.MAXNAME);
		this.attr_name = s.toString();
		this.rel_name = null;
	}
	
	public Attribute(String name, int type, int length, boolean key){
		StringBuffer s = new StringBuffer(name);
		s.setLength(Constant.MAXNAME);
		this.attr_name = s.toString();
		this.attr_type = type;
		this.attr_length = length;
		this.key = key;
	}
	
	public Attribute(String name, int type, int length, String rel, String attr, boolean foreign_key){
		StringBuffer s = new StringBuffer(name);
		s.setLength(Constant.MAXNAME);
		this.attr_name = s.toString();
		this.attr_type = type;
		this.attr_length = length;
		this.foreign_rel = rel;
		this.foreign_attr = attr;
		this.foreign_key = foreign_key;
	}
	
	public String GetRelName(){
		return this.rel_name;
	}
	
	public String GetAttr_Name(){
		return this.attr_name;
	}
	
	public void SetAttrName(String s){
		this.attr_name = s;
	}
	
	public int GetAttr_Type(){
		return this.attr_type;
	}
	
	public int GetAttr_Length(){
		return this.attr_length;
	}
	
	public boolean GetKey(){
		return this.key;
	}
}